package com.youkeda.redpacket.dataobject;

import java.io.Serializable;
import java.util.Date;

import com.youkeda.redpacket.model.User;
import com.youkeda.redpacket.util.UUIDUtils;
import lombok.Data;
import org.springframework.beans.BeanUtils;
import org.springframework.util.StringUtils;

/**
 * user
 * @author 
 */
@Data
public class UserDO implements Serializable {
    private String id;

    private String mobile;

    private Integer valid;

    private String nickname;

    private String avatar;

    private String password;

    private String gender;

    private Date gmtCreated;

    private Date gmtModified;

    private static final long serialVersionUID = 1L;

    public UserDO(User user){
        if (StringUtils.isEmpty(user.getId())){
            this.id = user.getId();
        }
        this.avatar = user.getAvatar();
        this.mobile = user.getMobile();
        this.gender = user.getGender();
        this.nickname =user.getNickname();
        this.password = this.getPassword();
        this.valid = this.getValid();
    }

    public User convertTOModel(){
        User user = new User();
        BeanUtils.copyProperties(this,user);
        return user;
    }
}